//
// CLandscapeVBAllocator.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

public class CLandscapeVBAllocator {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CLandscapeVBAllocator(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CLandscapeVBAllocator obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CLandscapeVBAllocator(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CLandscapeVBAllocator(CLandscapeVBAllocator.TType type, String vbName) {
    this(nel3dJNI.new_CLandscapeVBAllocator(type.swigValue(), vbName), true);
  }

  public void updateDriver(IDriver driver) {
    nel3dJNI.CLandscapeVBAllocator_updateDriver(swigCPtr, this, IDriver.getCPtr(driver), driver);
  }

  public void clear() {
    nel3dJNI.CLandscapeVBAllocator_clear(swigCPtr, this);
  }

  public boolean reallocationOccurs() {
    return nel3dJNI.CLandscapeVBAllocator_reallocationOccurs(swigCPtr, this);
  }

  public void resetReallocation() {
    nel3dJNI.CLandscapeVBAllocator_resetReallocation(swigCPtr, this);
  }

  public void checkVertexBuffersResident() {
    nel3dJNI.CLandscapeVBAllocator_checkVertexBuffersResident(swigCPtr, this);
  }

  public long allocateVertex() {
    return nel3dJNI.CLandscapeVBAllocator_allocateVertex(swigCPtr, this);
  }

  public void deleteVertex(long vid) {
    nel3dJNI.CLandscapeVBAllocator_deleteVertex(swigCPtr, this, vid);
  }

  public void lockBuffer(CFarVertexBufferInfo farVB) {
    nel3dJNI.CLandscapeVBAllocator_lockBuffer__SWIG_0(swigCPtr, this, CFarVertexBufferInfo.getCPtr(farVB), farVB);
  }

  public void lockBuffer(CNearVertexBufferInfo tileVB) {
    nel3dJNI.CLandscapeVBAllocator_lockBuffer__SWIG_1(swigCPtr, this, CNearVertexBufferInfo.getCPtr(tileVB), tileVB);
  }

  public void unlockBuffer() {
    nel3dJNI.CLandscapeVBAllocator_unlockBuffer(swigCPtr, this);
  }

  public boolean bufferLocked() {
    return nel3dJNI.CLandscapeVBAllocator_bufferLocked(swigCPtr, this);
  }

  public void activate(long vpId) {
    nel3dJNI.CLandscapeVBAllocator_activate(swigCPtr, this, vpId);
  }

  public final static class TType {
    public final static TType Far0 = new TType("Far0");
    public final static TType Far1 = new TType("Far1");
    public final static TType Tile = new TType("Tile");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TType.class + " with value " + swigValue);
    }

    private TType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TType(String swigName, TType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TType[] swigValues = { Far0, Far1, Tile };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
